﻿@using mscook.mvc;
@model mscook.mvc.Models.BaseModel

<form method="get"  action="@Url.Action("Index")" id="searchForm">
    <input type="hidden" id="num" name="num" value="@ViewData[ViewDataKeys.CURRENT_PAGE]" />
    <input type="hidden" id="keyword" name="keyword" value="@ViewData["Keyword"]" />
    <div class="menu_main">
        @{
            for (int i = 0; i < Model.ResourceTypes.Count; i++)
            {
                var parent = Model.ResourceTypes.ElementAt(i);
                var childList = Model.ChildResourceTypes.Where(o => o.ParentType == parent).ToList();

                string value = "";
                foreach (var child in childList)
                {
                    if (Model.SelectResourceTypes.Contains(child.Id))
                    {
                        value = child.Id;
                        break;
                    }
                }
            
            <input type="hidden" id="@Html.Encode("ptype" + i)" name="resourceTypes" value="@value" />            
                            
            <dl class="clearfix">
                <dt>@Html.Encode(parent.Name)</dt>
                <dd class="clearfix">
                    @foreach (var child in childList)
                    {
                        string css = Model.SelectResourceTypes.Contains(child.Id) ? "chosed" : "";
                        <a data-link-input="@Html.Encode("ptype" + i)" class="@css" data-id="@child.Id">@child.Name</a>
                        Model.ChildResourceTypes.Remove(child);
                    }

                </dd>
            </dl>
                                
                            
            }
        }

    </div>
</form>
